﻿using System;
using System.Collections;
using System.Text;

namespace Tetris
{
    [Serializable]
    public class Arrow : Shape
    {
        //global number of state for the shape
        public static int NbState = 4;

        /// <summary>
        /// basic instructor
        /// </summary>
        public Arrow() : base()
        {
            points.Clear();
        }

        /// <summary>
        ///  special constructor 
        /// </summary>
        public Arrow(bool test) :base()
        {
            points[0].X=4;
            points[0].Y=1;
            points[1].X=3;
            points[1].Y=1;
            points[2].X=4;
            points[2].Y=0;
            points[3].X=5;
            points[3].Y=1;
            state = 1;
        }

        /// <summary>
        /// Organized how the arrow will rotate according to its current state
        /// </summary>
        /// <param name="sens">Shape.COUNTCLOCKWISE or Shape.CLOCKWISE</param>
        public override void rotate(int sens)
        {
            //check that 0=>state<=4
            if (state > Arrow.NbState) this.state = 1;
            if (state < 1) this.state = Arrow.NbState;

            switch(state)
            {
                case 1:
                    points[1].X=points[1].X + 1;
                    points[1].Y=points[1].Y + (-1 * sens);
                    points[2].X=points[2].X + (1*sens);
                    points[2].Y=points[2].Y + 1;
                    points[3].X=points[3].X - 1;
                    points[3].Y=points[3].Y + (1*sens);
                    this.state += sens;
                    break;

                case 2:
                    points[1].X=points[1].X + (1*sens);
                    points[1].Y=points[1].Y + 1;
                    points[2].X=points[2].X -1;
                    points[2].Y=points[2].Y + (1 * sens);
                    points[3].X=points[3].X - (1*sens);
                    points[3].Y=points[3].Y - 1;
                    this.state += sens;
                    break;

                case 3:
                    points[1].X=points[1].X -1;
                    points[1].Y=points[1].Y + (1*sens);
                    points[2].X=points[2].X - (1*sens);
                    points[2].Y=points[2].Y - 1;
                    points[3].X=points[3].X + 1;
                    points[3].Y=points[3].Y - (sens*1);
                    this.state += sens;  
                    break;

                case 4:
                    points[1].X=points[1].X - (1*sens);
                    points[1].Y=points[1].Y - 1;
                    points[2].X=points[2].X + 1;
                    points[2].Y=points[2].Y - (1*sens);
                    points[3].X=points[3].X + (1*sens);
                    points[3].Y=points[3].Y + 1;
                    this.state += sens;
                    break;
            }
        }

    }
}
